﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Indigo=System.ServiceModel.Description;
using System.IdentityModel.Selectors;

namespace Microsoft.Cryptography.WCF
{
    /// <summary>
    /// Configures a service credential. Use this class to specify the credential for the service such a X.509 certificate. 
    /// Also, use this class to specify the authentication model for various client credentials such as username and password 
    /// validation. This implementation extends the base class 
    /// (<see cref="System.ServiceModel.Description.ServiceCredentials"/>) to support RSA-Signatures with SHA-2 
    /// encryption in XML-Signatures by returning an instance of 
    /// <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsSecurityTokenManager"/> instead  of 
    /// <see cref="System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager"/> when calling the method 
    /// CreateSecurityTokenManager
    /// </summary>
    public class ServiceCredentials : Indigo.ServiceCredentials
    {

        /// <summary>
        /// Configures a service credential. Use this class to specify the credential for the service such a X.509 certificate. 
        /// Also, use this class to specify the authentication model for various client credentials such as username and password 
        /// validation. This implementation extends the base class 
        /// (<see cref="System.ServiceModel.Description.ServiceCredentials"/>) to support RSA-Signatures with SHA-2 
        /// encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        public ServiceCredentials()
        {
        }

        /// <summary>
        /// Configures a service credential. Use this class to specify the credential for the service such a X.509 certificate. 
        /// Also, use this class to specify the authentication model for various client credentials such as username and password 
        /// validation. This implementation extends the base class 
        /// (<see cref="System.ServiceModel.Description.ServiceCredentials"/>) to support RSA-Signatures with SHA-2 
        /// encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        /// <param name="credentials">The <see cref="System.ServiceModel.Description.ServiceCredentials"/> instance used to initialize the new instance.</param>
        protected ServiceCredentials(ServiceCredentials credentials)
            : base(credentials)
        {
        }

        /// <summary>
        /// Creates a security token manager for this instance.This method is rarely called explicitly; it is primarily used 
        /// in extensibility scenarios and is called by the system itself. This implementation This implementation extends 
        /// the base class (<see cref="System.ServiceModel.Description.ServiceCredentials"/>) to support RSA-Signatures 
        /// with SHA-2 encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        /// <returns>Returns a security token manager for this instance.This method is rarely called explicitly; it is primarily used 
        /// in extensibility scenarios and is called by the system itself. This implementation This implementation extends 
        /// the base class (<see cref="System.ServiceModel.Description.ServiceCredentials"/>) to support RSA-Signatures 
        /// with SHA-2 encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager</returns>
        public override SecurityTokenManager CreateSecurityTokenManager()
        {
            return new ServiceCredentialsSecurityTokenManager((ServiceCredentials)this.Clone());
        }

        /// <summary>
        /// Creates a new copy of this <see cref="Microsoft.Cryptography.WCF.ServiceCredentials"/> instance.
        /// </summary>
        /// <returns>Returns a new copy of this <see cref="Microsoft.Cryptography.WCF.ServiceCredentials"/> instance.</returns>
        protected override Indigo.ServiceCredentials CloneCore()
        {
            return new ServiceCredentials(this);
        }

        
    }
}

